<!-- 
  * @Description:产品服务的搜索框 
  * @Author:lxy 
  * @Date:2023-03-24 10:23  
-->
<template>
  <div class="bioati">
    <el-form
      ref="searchFromRef"
      :model="searchFromData"
      :inline="true"
      class="demo-ruleForm"
    >
      <el-row type="flex" justify="space-between">
        <el-form-item label="用户名：">
          <el-input
            placeholder="请输入"
            v-model="searchFromData.username"
          ></el-input>
        </el-form-item>
        <el-form-item label="类型：">
          <el-select v-model="searchFromData.type" placeholder="请选择">
            <el-option
              v-for="item in options2"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态：">
          <el-select v-model="searchFromData.disableUser" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="注册时间：">
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm:ss"
            v-model="searchFromData.userEntryTime"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item>
          <div style="text-align: right">
            <el-button icon="el-icon-refresh" @click="resetForm"
              >重置</el-button
            >
            <el-button type="primary" icon="el-icon-search" @click="submitFrom"
              >查询</el-button
            >
          </div>
        </el-form-item>
      </el-row>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "searchFrom",
  data() {
    return {
      searchFromData: {
        username: "",
        disableUser: "aa",
        type: 0,
        userEntryTime: null,
      },
      options: [
        {
          value: "aa",
          label: "全部",
        },
        {
          value: 1,
          label: "正常",
        },
        {
          value: 2,
          label: "禁用",
        },
      ],
      options2: [
        {
          value: 0,
          label: "全部",
        },
        {
          value: 1,
          label: "普通管理员",
        },
        {
          value: 2,
          label: "高级管理员",
        },
      ],
    };
  },
  methods: {
    submitFrom() {
      this.$emit("forSubmit", 1);
    },
    getSearchForm() {
      //方便外面主动来获取数据
      return this.searchFromData;
    },
    //日期清除
    changeHandler(val) {
      if (!val) this.$emit("forSubmit", 1);
    },
    resetForm() {
      //重置操作
      this.searchFromData.username = "";
      this.searchFromData.disableUser = "aa";
      this.searchFromData.type = 0;
      this.searchFromData.userEntryTime = null;
      //接着发送数据 进行网络请求
      this.$emit("forSubmit", 1);
    },
  },
};
</script>

<style scoped lang="less">
.bioati {
  margin: 15px 0px;
  align-items: center;
  height: 40px;
}
.demo-ruleForm > .el-row {
  :deep(.el-form-item) {
    width: 360px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .el-form-item__label {
      white-space: nowrap !important;
    }
    .el-form-item__content {
      flex: 1;
    }
  }
}
:deep(.el-range-editor.el-input__inner) {
  padding: 0px 10px !important;
}
</style>
